import request from '@/utils/axios/instance';
// import type { RouteRecordNormalized } from 'vue-router';
import type {
  CaptchaImgRes,
  LoginData,
  LoginRes,
  UserRes,
  RouterRes,
  BaseResponse,
} from './types';

export function getCaptchaImage() {
  return request<CaptchaImgRes>({
    method: 'get',
    url: '/captchaImage',
  });
}

export async function login(data: LoginData) {
  return request<LoginRes>({
    method: 'post',
    url: '/login',
    data,
  });
}

export async function getUserInfo() {
  return request<UserRes>({
    method: 'get',
    url: '/getInfo',
  });
}

export async function logout() {
  return request({
    method: 'post',
    url: '/logout',
  });
}

export async function getRouters() {
  return request<BaseResponse<RouterRes>>({
    method: 'get',
    url: '/getRouters',
  });
}
